#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
const int N=35;
typedef pair<int,int> PII;

char labyrinth[N][N];
int stepcnt[N][N];
int n,m,x,y;
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};

void bfs()
{

	queue<PII> q;
	memset(stepcnt,-1,sizeof(stepcnt));
	stepcnt[x][y]=0;

	q.push({x,y});
	while(q.size())
	{
		auto coordinates=q.front();
		int x=coordinates.first;
		int y=coordinates.second;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int newx=x+dx[i];
			int newy=y+dy[i];
			if(newx>=1&&newx<=n&&newy>=1&&newy<=m&&
				labyrinth[newx][newy]!='*'
				&&stepcnt[newx][newy]==-1)
			{
				stepcnt[newx][newy]=stepcnt[x][y]+1;
				if(labyrinth[newx][newy]=='e') continue;
				q.push({newx,newy}); 
			}
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>labyrinth[i][j];
			if(labyrinth[i][j]=='k')
			{
				x=i,y=j;
			}
		}
	}

	bfs();
	int count=0,ret=1e9;
	
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(stepcnt[i][j]!=-1&&labyrinth[i][j]=='e')
			{
				count++;
				ret=min(ret,stepcnt[i][j]);
			}
		}
	}

	if(count)
	{
		cout<<count<<" "<<ret<<endl;
	}
	else
	{
		cout<<-1<<endl;
	}
}